package com.xuecheng.system.controller;

import com.xuecheng.api.sysetm.DictionaryApi;
import com.xuecheng.api.sysetm.model.dto.DictionaryDTO;
import com.xuecheng.system.service.DictionaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class DictionaryController implements DictionaryApi {

    @Autowired
    private DictionaryService  dictionaryService;

    //查询全部字典信息
   @GetMapping("/dictionary/all")
    public List<DictionaryDTO> queryAll() {
       List<DictionaryDTO> dtoList = dictionaryService.queryAll();
       return dtoList;
    }

    //根据code查询字典信息
    @GetMapping("/dictionary/code/{code}")
    public DictionaryDTO queryByCode(@PathVariable String code) {
        DictionaryDTO dictionaryDTO = dictionaryService.queryByCode(code);
        return dictionaryDTO;
    }
}
